package com.atom.process.cnmuseum.bm.dao.process;


import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Repository;

import com.atom.common.dao.AvensCommonDao;
import com.atom.common.exception.AvensNullPointerException;
import com.atom.common.mb.entity.gl.XzxxDO;
import com.atom.common.remote.user.UserUtil;
import com.atom.process.cnmuseum.bm.entity.process.BmXzxxProcessDO;

@Repository
public class BmXzxxProcessDao extends AvensCommonDao<BmXzxxProcessDO> {
    public BmXzxxProcessDO findByProcessInstanceId(String processId) {
        List<BmXzxxProcessDO> list = super.findByProperty("processId", processId);
        if (list == null || list.size() == 0) {
            throw new AvensNullPointerException("ProcessDO is null where processId = " + processId);
        } else {
            return list.get(0);
        }
    }


    public void createPDO(UserUtil user, String processInstanceId, String title, XzxxDO xzxx) {
        BmXzxxProcessDO pdo = new BmXzxxProcessDO();
        BeanUtils.copyProperties(xzxx, pdo, "id");
        pdo.setProcessId(processInstanceId);
        super.save(pdo);
    }

}
